# gozerlib/botbase.py
#
#

""" base class for all bots. """

## gozerlib imports

from plugins import plugs
from less import Less

## basic imports

import time

class BotBase(object):

    def __init__(self, name, *args, **kwargs):
        self.type = ""
        self.name = name
        self.nick = self.name
        self.starttime = time.time()
        self.outcache = Less(1)
        self.channels = {}

    def doevent(self, event):

        """ 
            dispatch an event. 

            :param event: event to dispatch.
            :rtype: None

        """

        plugs.dispatch(self, event)

    def ownercheck(self, userhost):

        """
            check if provided userhost belongs to an owner. 

            :param userhost: userhost to check.
            :type userhost: string
            :rtype: boolean

        """

        from gozerlib.config import Config
        config = Config('mainconfig')

        if userhost in config['owner']:
            return True

        return False

    def say(self, channel, txt):

        """
            override this. 

            :param channel: channel to send txt to
            :type channel: string
            :param txt: text to send
            :type txt: string
            :rtype: None

        """

        pass

    def sayroot(self, channel, txt):

        """
            override this. 

            :param channel: channel to send txt to
            :type channel: string
            :param txt: text to send
            :type txt: string
            :rtype: None

        """

        pass
